var cc__decorate = __decorate;
var cc__awaiter = __awaiter;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ConstValue = require("ConstValue");
var $2GameUser = require("GameUser");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2ccUtil = require("ccUtil");
var $2UIHelp = require("UIHelp");
var $2BaseUIPopup = require("BaseUIPopup");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UISidebar = /* */function (_h$default2) {
  function _ctor() {
    var _this131;
    babel_classCallCheck(this, _ctor);
    _this131 = _callSuper(this, _ctor, arguments);
    _this131.closeBtn = null;
    _this131.enterBtn = null;
    _this131.receiveBtn = null;
    _this131.receivedLbl = null;
    return _this131;
  }
  babel_inherits(_ctor, _h$default2);
  return babel_createClass(_ctor, [{
    key: "onLoad",
    value: function onLoad() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onLoad", this).call(this);
      $2EventCenter.default.regisEvent($2EventDefine.default.SIDEBAR_ENTER_STATE, this.syncSiderbarView, this);
    }
  }, {
    key: "onDestroy",
    value: function onDestroy() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onDestroy", this).call(this);
      $2EventCenter.default.removeEvent($2EventDefine.default.SIDEBAR_ENTER_STATE, this.syncSiderbarView, this);
    }
  }, {
    key: "onShow",
    value: function onShow() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onShow", this).call(this);
      this.syncSiderbarView();
    }
  }, {
    key: "syncSiderbarView",
    value: function syncSiderbarView() {
      this.receivedLbl.active = false;
      this.receiveBtn.active = false;
      this.enterBtn.active = false;
      if ($2GameUser.default.getInstance().getSidebarRewardClaimState()) {
        this.receivedLbl.active = true;
      } else if ($2ConstValue.ConstValue.SidebarEnterGame) {
        this.receiveBtn.active = true;
      } else {
        this.enterBtn.active = true;
      }
    }
  }, {
    key: "onEnter",
    value: function onEnter() {
      var e = window.tt;
      e && e.navigateToScene && e.navigateToScene({
        scene: "sidebar",
        success(e) {
          console.log("navigate to scene success", e);
        },
        fail(e) {
          console.log("navigate to scene fail: ", e);
        }
      });
    }
  }, {
    key: "onReceive",
    value: function onReceive() {
      return cc__awaiter(this, undefined, undefined, /* */babel_regeneratorRuntime().mark(function _callee10() {
        return babel_regeneratorRuntime().wrap(function _callee10$(_context11) {
          while (1) {
            switch (_context11.prev = _context11.next) {
              case 0:
                $2GameUser.default.getInstance().tili++;
                _context11.next = 3;
                return $2ccUtil.default.goldFlyEffect();
              case 3:
                $2EventCenter.default.postEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE);
                $2UIHelp.UIHelp.showTip("领取1点体力");
                $2GameUser.default.getInstance().setSidebarRewardClaimState(true);
                this.syncSiderbarView();
              case 7:
              case "end":
                return _context11.stop();
            }
          }
        }, _callee10, this);
      }));
    }
  }, {
    key: "onClose",
    value: function onClose() {
      this.close();
    }
  }, {
    key: "onEnable",
    value: function onEnable() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onEnable", this).call(this);
      this.closeBtn.on("click", this.onClose, this);
      this.enterBtn.on("click", this.onEnter, this);
      this.receiveBtn.on("click", this.onReceive, this);
    }
  }, {
    key: "onDisable",
    value: function onDisable() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onDisable", this).call(this);
      this.closeBtn.off("click", this.onClose, this);
      this.enterBtn.off("click", this.onEnter, this);
      this.receiveBtn.off("click", this.onReceive, this);
    }
  }]);
}($2BaseUIPopup.default);
def_UISidebar.className = "UISidebar";
cc__decorate([ccp_property(cc.Node)], def_UISidebar.prototype, "closeBtn", undefined);
cc__decorate([ccp_property(cc.Node)], def_UISidebar.prototype, "enterBtn", undefined);
cc__decorate([ccp_property(cc.Node)], def_UISidebar.prototype, "receiveBtn", undefined);
cc__decorate([ccp_property(cc.Node)], def_UISidebar.prototype, "receivedLbl", undefined);
def_UISidebar = cc__decorate([ccp_ccclass], def_UISidebar);
exports.default = def_UISidebar;